package cn.tedu.micro.demo.device.service;

import cn.tedu.micro.demo.common.pojo.po.GunInfoPO;
import cn.tedu.micro.demo.common.pojo.vo.GunInfoVO;
import cn.tedu.micro.demo.device.repository.GunRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class GunServiceImpl implements GunService{
    @Autowired
    private GunRepository gunRepository;

    @Override
    public GunInfoVO gunDetail(Long gunId) {
        //仓储层读取的是PO
        GunInfoPO gunInfo=gunRepository.getGunById(gunId);
        //严谨业务判断 gunInfo不一定存在
        if (gunInfo!=null){
            //业务层返回的是VO
            GunInfoVO gunInfoVO=new GunInfoVO();
            gunInfoVO.setId(gunInfo.getId());
            gunInfoVO.setStatus(gunInfo.getStatus());
            gunInfoVO.setType(gunInfo.getType());
            return gunInfoVO;
        }
        return null;
    }
}
